package com.hrc.springbootdemo.controller;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @GetMapping("/")
    public String testZ(){
        return "spring boot web starter success";
    }

    @DeleteMapping("/")
    public void test3(){

    }


    @GetMapping("/authorize")
    public void test(HttpServletResponse response){
        //401 WWW-Authenticate: Basic ` 让浏览器自动弹出登录框
        response.setHeader("WWW-Authenticate", "Basic realm=\" Spring Security\"");
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}
